#pragma once

#include <QtWidgets/QMainWindow>
#include "ui_QrcodeMakeTool.h"
#include "SerialPortObject.h"
#include <QKeyEvent>
#include "TcpClient.h"

class QrcodeMakeTool : public QMainWindow
{
	Q_OBJECT

public:
	QrcodeMakeTool(QWidget *parent = Q_NULLPTR);
	~QrcodeMakeTool();

	void initData();
	void createAction();
	void diyUi();
	void startSerialPortThread();
	void keyPressEvent(QKeyEvent *event);
	void addItemContent(int row, int column, QString content, QTableWidget*  ptableWidget, int color);
	void slotPrintLog();
	void startDataDealThread();

signals:
	void SignalSendDataqToSerialPort(int type, QByteArray dataReceived);
	void signalSendOrder(QString strMsgSend, int orderType);

	private slots:
	void slotRequest(QString strMsgSend,int orderType);
	void SlotButtonClicked();
	void SlotComboBoxClicked(QString strNewText);
	void SlotCheckBoxClicked();
	void slotReceiveDataFromSP(int type, QByteArray dataReceived);
	void slotStartPrint();
	void slotQRcodeGet(QString);

private:
	Ui::QrcodeMakeToolClass ui;

	SerialPortObject* m_serialPort;
	QThread* m_qthread;
	bool m_isSerialPortOpened;

	QTimer m_printStartTimer;

	int m_x;
	int m_y;
	int m_length;
	QString m_hartVersion;
	QString m_softVersion;
	QMap<QString, QString> m_softVersionList;

	TcpClientThread* m_clientSeverThread;
	QThread* m_clientThread;
};
